<template>
  <!-- 预约成功弹窗 -->
  <div v-if="showSuccessDialog" class="dialog-mask">
    <div class="dialog-card">
      <!-- 标题 -->
      <h2 class="dialog-title">预约成功，等待咨询师确认</h2>

      <!-- 内容区域 -->
      <div class="dialog-content">
        <div class="info-section">
          <h3>咨询师信息</h3>
          <p>{{ consultantInfo.name }} · {{ consultantInfo.title }}</p>
        </div>

        <div class="info-section">
          <h3>预约详情</h3>
          <p>方式：{{ appointmentInfo.method }}</p>
          <p>时间：{{ formatDateTime(appointmentInfo.time) }}</p>
          <p>地点：{{ appointmentInfo.location }}</p>
        </div>
      </div>

      <!-- 底部按钮 -->
      <button
          class="confirm-btn"
          @click="handleConfirm"
      >
        确认
      </button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showSuccessDialog: false,
      consultantInfo: {}, // 从接口获取的咨询师数据
      appointmentInfo: {} // 提交的预约数据
    }
  },
  methods: {
    // 提交预约成功后调用
    showDialog(responseData) {
      this.consultantInfo = responseData.consultant
      this.appointmentInfo = responseData.appointment
      this.showSuccessDialog = true
    },

    handleConfirm() {
      this.showSuccessDialog = false
      proxy.$router.push('/') // 使用 Vue Router 跳转首页
    },
  }
}
</script>

<style scoped>
.dialog-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}

.dialog-card {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  padding: 20px;
}

.dialog-title {
  color: #1890ff;
  margin-bottom: 15px;
}

.info-section {
  margin: 15px 0;
  padding: 10px;
  border-bottom: 1px solid #eee;
}

.confirm-btn {
  background: #1890ff;
  color: white;
  padding: 10px 25px;
  border-radius: 4px;
  margin-top: 15px;
  width: 100%;
}
</style>
